<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<title>每周点评-云校通-教师</title>
<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
<body ontouchstart class="week-comment" style="background: #FFFFFF;">
	<div class="weui_tab tab-bottom">
		<div class="weui-header bg-white hide" id="tips"> 
           <div class="weui-header-left"></div>
           <h3 class="weui-header-title f-black">请老师填写第<span id="weekNo"></span>周的评语</h3>
        </div>
		<div class="weui_tab_bd">
			<div class="weui_cells mt0 hide" id="fastComment">
	            <div class="weui_cell">
	            	<div class="weui_cell_bd weui_cell_primary">
	                    <p></p>
	                </div>
                	<div class="weui_cell_ft f-blue" onclick="showComment1()">评语快捷查看</div>
                </div>
			</div>
		    <div class="searchbar_wrap"></div>
		    <div class="weui_cells mt0 mb40" id="studentList">
		    </div>
		</div>
	</div>
	<div class="hide_main" id="hide_main">
	      <header>
	        <h5><span id="studentName"></span> 写评语</h5>
	        <img src="<%=basePath %>/images/iconC.png" onclick="hideComment()">
	      </header>
	      <ul id="weekList">
	      </ul>
	      <div class="tips">
	        <h4>圆内数字“1、2、3...”代表第几周。</h4>
	        <span class="bg-green"></span><p>绿色代表家长已回评语</p>
	        <span class="bg-blue"></span><p>蓝色代表老师已填评语</p>
	        <span class="bg-grey"></span><p>灰色代表老师未填评语</p>
	      </div>
    </div>
    <div class="hide_main" id="hide_main1">
	      <header>
	        <h5>周期列表</h5>
	        <img src="<%=basePath %>/images/iconC.png" onclick="hideComment()">
	      </header>
	      <ul id="weekList1">
	      </ul>
	      <div class="tips">
	        <h4>圆内数字“1、2、3...”代表第几周。</h4>
	      </div>
    </div>
    <div class="hide_black"></div>
<script>
	$(function(){
		if("${flag}" != "0") {
			$("#fastComment").show();
			studentList();
			currWeek();
		}else {
			$.alert("只有班主任、副班主任和生活老师才有权限操作！", "温馨提示");
		}
	})
	function showComment1() {
  		$(".hide_black").show();
  		$("#hide_main1").show();
  		var obj = $($($("#studentList").find(".weui_cell")[0]).find(".weui_btn_mini")[1]);
  		var studentId = obj.attr("data-id");
  		var grade = obj.attr("data-grade");
  		var clazz = obj.attr("data-clazz");
  		weekCommentByStudentId1(studentId, grade, clazz);
  	}
	function weekCommentByStudentId1(studentId, grade, clazz) {
  		$.ajax({
			url : basePath + "/ls/week/comment/studentId",
			type : "post",
			data : {
				studentId: studentId, 
				grade: grade, 
				clazz: clazz
			},
			dataType : "json",
			async : false,
			success : function(data) {
				if(data != null) {
					var html = '';
					for(var i in data) {
						var itm = data[i];
						var bg = "bg-gray";
						var fg = "f-black";
						var link = basePath + "/ls/week/comment/lookList?wno=" + itm.weekNo + "&grade=" + grade + "&clazz=" + clazz;
						html += '<li class="'+bg+'"><a href="'+link+'" class="'+fg+'">'+itm.weekNo+'</a></li>';
					}
					$("#weekList1").html(html);
				}
			}, error:function(){
				$.alert("查询异常","");
			}
		});
  	}
  	function showComment(thiz) {
  		$(".hide_black").show();
  		$("#hide_main").show();
  		$("#studentName").html($(thiz).attr("data-name"));
  		weekCommentByStudentId($(thiz).attr("data-id"));
  	}
  	function hideComment() {
  		$(".hide_black").hide();
  		$("#hide_main").hide();
  		$("#hide_main1").hide();
  	}
  	function weekCommentByStudentId(studentId) {
  		$.ajax({
			url : basePath + "/ls/week/comment/studentId",
			type : "post",
			data : {
				studentId: studentId
			},
			dataType : "json",
			async : false,
			success : function(data) {
				if(data != null) {
					var html = '';
					for(var i in data) {
						var itm = data[i];
						var bg = "bg-gray";
						var fg = "f-black";
						var link = basePath + "/ls/week/comment/write?sid=" + studentId + "&wno=" + itm.weekNo;
						if(itm.status == 1) {
							bg = "bg-blue";
							fg = "f-white";
							link = basePath + "/ls/week/comment/detail/" + itm.commentId;
						} else if(itm.status == 2) {
							bg = "bg-green";
							fg = "f-white";
							link = basePath + "/ls/week/comment/detail/" + itm.commentId;
						}
						html += '<li class="'+bg+'"><a href="'+link+'" class="'+fg+'">'+itm.weekNo+'</a></li>';
					}
					$("#weekList").html(html);
				}
			}, error:function(){
				$.alert("查询异常","");
			}
		});
  	}
  	function studentList() {
  		$.ajax({
			url : basePath + "/ls/week/comment/studentList",
			type : "post",
			dataType : "json",
			async : false,
			success : function(data) {
				if(data != null) {
					var html = "";
					for(var i in data) {
						var itm = data[i];
						html += '<div class="weui_cell">\
			                <div class="weui_cell_hd"><img class="circle bg-blue-b" src="<%=basePath %>/images/siliao_touxiang@3x.png" style="width:50px;margin-right:20px;display:block"></div>\
			                <div class="weui_cell_bd weui_cell_primary">\
			                    <p>'+itm.studentNum + ' ' + itm.studentName+'</p>\
			                </div>\
			                <div class="weui_cell_ft">\
		                        <span style="position: relative;display: inline-block;">\
		                          <a href="<%=basePath%>/ls/week/comment/studentPage/'+itm.studentId+'" class="weui_btn weui_btn_mini bg-green-b">家长\
		                          <span class="weui-badge bg-green">'+itm.parentWeekNo+'</span>\
		                          </a> \
		                        </span>\
		           				<span style="position: relative;display: inline-block;">\
		                         		<a class="weui_btn weui_btn_mini bg-blue-b" data-grade="'+itm.grade+'" data-clazz="'+itm.clazz+'" data-id="'+itm.studentId+'" data-name="'+itm.studentName+'" onclick="showComment(this)">写评语\
		                         			<span class="weui-badge bg-blue ">'+itm.teacherWeekNo+'</span>\
		                         		</a>\
		                       	</span>\
			                </div>\
			            </div>';
					}
				}
				$("#studentList").html(html);
			}, error:function(){
				$.alert("查询异常","");
			}
		});
  	}
  	function currWeek() {
  		$.ajax({
			url : basePath + "/ls/week/comment/currWeek",
			type : "post",
			dataType : "json",
			async : false,
			success : function(data) {
				if(data != null) {
					$("#tips").show();
					$("#weekNo").html(data);
				}
			}, error:function(){
				$.alert("查询异常","");
			}
		});
  	}
</script>
</body>
<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
</html>